package com.eagledata.project.business.vehicleInfo.service;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.eagledata.common.utils.StringUtil;
import com.eagledata.project.business.vehicleInfo.mapper.VehicleInfoMapper;
import com.eagledata.project.business.vehicleInfo.domain.VehicleInfo;
import com.eagledata.project.business.vehicleInfo.service.IVehicleInfoService;

/**
 * 车辆 服务层实现
 * 
 * @author eagledata
 * @date 2018-09-09
 */
@Service
public class VehicleInfoServiceImpl implements IVehicleInfoService 
{
	@Autowired
	private VehicleInfoMapper vehicleInfoMapper;
	
	/**
     * 查询车辆信息
     * 
     * @param id 车辆ID
     * @return 车辆信息
     */
	 @Override
	public VehicleInfo selectVehicleInfoById(Long id) {
	    return vehicleInfoMapper.selectVehicleInfoById(id);
	}
	
	/**
     * 查询车辆列表
     * 
     * @param vehicleInfo 车辆信息
     * @return 车辆集合
     */
	 @Override
	public List<VehicleInfo> selectVehicleInfoList(VehicleInfo vehicleInfo) {
	    return vehicleInfoMapper.selectVehicleInfoList(vehicleInfo);
	}
	
    /**
     * 新增车辆
     * 
     * @param vehicleInfo 车辆信息
     * @return 结果
     */
	 @Override
	public int insertVehicleInfo(VehicleInfo vehicleInfo) {
	    return vehicleInfoMapper.insertVehicleInfo(vehicleInfo);
	}
	
	/**
     * 修改车辆
     * 
     * @param vehicleInfo 车辆信息
     * @return 结果
     */
	 @Override
	public int updateVehicleInfo(VehicleInfo vehicleInfo) {
	    return vehicleInfoMapper.updateVehicleInfo(vehicleInfo);
	}
	
	/**
     * 保存车辆
     * 
     * @param vehicleInfo 车辆信息
     * @return 结果
     */
	 @Override
	public int saveVehicleInfo(VehicleInfo vehicleInfo) {
	    Long id = vehicleInfo.getId();
		int rows = 0;
		if (StringUtil.isNotNull(id)) {
		    rows = vehicleInfoMapper.updateVehicleInfo(vehicleInfo);
		} else {
		    rows = vehicleInfoMapper.insertVehicleInfo(vehicleInfo);
		}
		return rows;
	}
	
	/**
     * 删除车辆信息
     * 
     * @param id 车辆ID
     * @return 结果
     */
	 @Override
	public int deleteVehicleInfoById(Long id) {
	    return vehicleInfoMapper.deleteVehicleInfoById(id);
	}
	
	/**
     * 批量删除车辆对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
	 @Override
	public int batchDeleteVehicleInfo(Long[] ids) {
		return vehicleInfoMapper.batchDeleteVehicleInfo(ids);
	}
	
}
